﻿using Batman.Core.Dtos;
using System;
using System.Collections.Generic;
using System.Text;

namespace Batman.Core
{
    public class ResponseBase<T>
    {
        public int Code { get; set; }

        public bool Success { get; set; } = true;

        public string Message { get; set; }

        public T Result { get; set; }

        public ResponseBase() { }

        public ResponseBase(bool success) => this.Success = success;

        public ResponseBase(bool success, string message)
        {
            this.Success = success;
            this.Message = message;
        }

        public ResponseBase(int errCode, string message)
        {
            this.Code = errCode;
            this.Success = false;
            this.Message = message;
        }

        public ResponseBase(T result)
        {
            this.Success = true;
            this.Result = result;
        }
    }

    public class ResponseBase : ResponseBase<object>
    {
        public ResponseBase()
        {
        }

        public ResponseBase(object result) : base(result)
        {
        }

        public ResponseBase(bool success) : base(success)
        {
        }

        public ResponseBase(int errCode, string message) : base(errCode, message)
        {
        }

        public ResponseBase(bool success, string message) : base(success, message)
        {
        }
    }

    public class PagedResponse : ResponseBase<object>
    {
        private PagedResponse(object result)
        {
            this.Result = result;
        }

        public static PagedResponse New<T>(int total, List<T> items)
        {
            var result = new PagedResultDto<T>(total, items);
            return new PagedResponse(result);
        }
    }

}
